/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.farmcode.api.runtime.metadata.tables;

import com.farmcode.api.runtime.metadata.Child;
import java.io.Serializable;

/**
 *
 * @author oiprado
 */
public class Attribute extends Child implements Serializable {

    /**
     *
     */
    private static final long serialVersionUID = 1L;
    private String precision;
    private String identity;
    private String pk;
    private String fk;
    private String fkTable;
    private String nativeType;
    private String dataType;
    private String nullable;

    public Attribute() {
    }

    public Attribute(String name, String type, String precision, String identity, String pk, String fk, String fkTable, String nativeType, String dataType, String nullable) {
        super(name, type, true);
        this.precision = precision;
        this.identity = identity;
        this.pk = pk;
        this.fk = fk;
        this.fkTable = fkTable;
        this.nativeType = nativeType;
        this.dataType = dataType;
        this.nullable = nullable;
    }

    

    public Attribute(String name, String value) {
        super(name, "", true);
    }
    /**
     * @return the precision
     */
    public String getPrecision() {
        return precision;
    }

    /**
     * @param precision the precision to set
     */
    public void setPrecision(String precision) {
        this.precision = precision;
    }

    /**
     * @return the identity
     */
    public String getIdentity() {
        return identity;
    }

    /**
     * @param identity the identity to set
     */
    public void setIdentity(String identity) {
        this.identity = identity;
    }

    /**
     * @return the pk
     */
    public String getPk() {
        return pk;
    }

    /**
     * @param pk the pk to set
     */
    public void setPk(String pk) {
        this.pk = pk;
    }

    /**
     * @return the fk
     */
    public String getFk() {
        return fk;
    }

    /**
     * @param fk the fk to set
     */
    public void setFk(String fk) {
        this.fk = fk;
    }

    /**
     * @return the fTable
     */
    public String getfkTable() {
        return fkTable;
    }

    /**
     * @param fTable the fTable to set
     */
    public void setfkTable(String fTable) {
        this.fkTable = fTable;
    }

    /**
     * @return the nativeType
     */
    public String getNativeType() {
        return nativeType;
    }

    /**
     * @param nativeType the nativeType to set
     */
    public void setNativeType(String nativeType) {
        this.nativeType = nativeType;
    }

    /**
     * @return the dataType
     */
    public String getDataType() {
        return dataType;
    }

    /**
     * @param dataType the dataType to set
     */
    public void setDataType(String dataType) {
        this.dataType = dataType;
    }

    /**
     * @return the nullable
     */
    public String getNullable() {
        return nullable;
    }

    /**
     * @param nullable the nullable to set
     */
    public void setNullable(String nullable) {
        this.nullable = nullable;
    }

    public boolean isGuid() {
        return getName().equalsIgnoreCase("guid");
    }

    @Override
    public String toString() {
        return  "<attribute  name=\""+getName() +
                "\" type=\""+getType() +
                "\" precision=\""+getPrecision()+
                "\" identity=\""+getIdentity() +
                "\" pk=\""+getPk()+
                "\" fk=\""+getFk() +
                "\" fkTable=\""+getfkTable() +
                "\" nativeType=\""+getNativeType() +
                "\" dataType=\""+getDataType()+
                "\" nullable=\""+getNullable() +"\"/>";
    }
    
    
}
